// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   AddressServiceImp.java

package com.iphaeton.lms.business.address;

import com.iphaeton.exception.BusinessException;
import com.iphaeton.exception.PersistenceException;
import com.iphaeton.lms.business.PersistentServiceSupport;
import com.iphaeton.lms.pojo.address.Address;
import com.iphaeton.persistence.IPersistenceService;
import java.util.List;
import org.apache.log4j.Logger;

// Referenced classes of package com.iphaeton.lms.business.address:
//            IAddressService

public class AddressServiceImp extends PersistentServiceSupport
    implements IAddressService
{

    public AddressServiceImp()
    {
    }

    public Address save(Address addr)
        throws BusinessException
    {
        try
        {
            addr = (Address)hbpservice.store(addr);
        }
        catch(PersistenceException e)
        {
            e.printStackTrace();
            throw new BusinessException("\u5B58\u50A8\u8054\u7CFB\u4EBA\u4FE1\u606F\u5230\u6570\u636E\u5E93\u65F6\u51FA\u9519!");
        }
        return addr;
    }

    public Address findAddressById(String id)
        throws BusinessException
    {
        Address addr;
        try
        {
            addr = (Address)hbpservice.get(id, com.iphaeton.lms.pojo.address.Address.class);
        }
        catch(PersistenceException e)
        {
            e.printStackTrace();
            throw new BusinessException("\u6839\u636EID\u67E5\u8BE2\u8054\u7CFB\u4EBA\u4FE1\u606F\u51FA\u9519!");
        }
        return addr;
    }

    public void remove(String id)
        throws BusinessException
    {
        try
        {
            hbpservice.remove(id, com.iphaeton.lms.pojo.address.Address.class);
        }
        catch(PersistenceException e)
        {
            e.printStackTrace();
            throw new BusinessException("\u6839\u636EID\u5220\u9664\u8054\u7CFB\u4EBA\u4FE1\u606F\u51FA\u9519!");
        }
    }

    public List findAddress(String user_id, String sort_id)
        throws BusinessException
    {
        String hql = "from Address addr where addr.userId='" + user_id + "'";
        if(!sort_id.equals("") && sort_id != null)
            hql = hql + " and addr.sortId='" + sort_id + "'";
        hql = hql + " order by addr.sortId,addr.name";
        List list;
        try
        {
            list = hbpservice.query(hql);
        }
        catch(PersistenceException e)
        {
            e.printStackTrace();
            throw new BusinessException("\u67E5\u8BE2\u7528\u6237\u8054\u7CFB\u4EBA\u4FE1\u606F\u5217\u8868\u51FA\u9519!");
        }
        return list;
    }

    public List findSort()
        throws BusinessException
    {
        String hql = "from AddressSort sort order by sort.id";
        List list;
        try
        {
            list = hbpservice.query(hql);
        }
        catch(PersistenceException e)
        {
            e.printStackTrace();
            throw new BusinessException("\u67E5\u8BE2\u7528\u6237\u8054\u7CFB\u4EBA\u5206\u7C7B\u51FA\u9519!");
        }
        return list;
    }

    private static Logger logger;
    static Class class$0; /* synthetic field */
    static Class class$1; /* synthetic field */

    static 
    {
        logger = Logger.getLogger(com.iphaeton.lms.business.address.AddressServiceImp.class.getName());
    }
}
